package com.flurry.android;

import android.text.TextUtils;
import android.util.Log;
import com.flurry.android.responses.AppCloudApplyOperationResonseHandler;
import com.flurry.android.responses.AppCloudCommonOperationResponseHandler;
import com.flurry.android.responses.AppCloudError;
import com.flurry.android.responses.AppCloudGetUserByIDResponseHandler;
import com.flurry.android.responses.AppCloudLoginResponseHandler;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;

public class AppCloudUser extends cx
{
  private static AppCloudUser cN = null;

  public AppCloudUser()
  {
  }

  public AppCloudUser(String paramString1, String paramString2, String paramString3)
  {
    this.mUsername = paramString1;
    this.mEmail = paramString2;
    this.password = paramString3;
  }

  AppCloudUser(JSONObject paramJSONObject)
  {
    createUser(paramJSONObject);
  }

  protected static AppCloudSearch Search()
  {
    if (getCurrentUser() == null)
      return null;
    return new AppCloudSearch();
  }

  private static void a(String paramString1, String paramString2, AppCloudCommonOperationResponseHandler paramAppCloudCommonOperationResponseHandler)
  {
    try
    {
      ArrayList localArrayList = new ArrayList();
      if (paramString1 != null)
        localArrayList.add(new BasicNameValuePair("username", paramString1));
      while (true)
      {
        FlurryAppCloudRequestManager.fInternalApi = true;
        FlurryAppCloudRequestManager.Post("v1/user/forgot", localArrayList, new di(paramAppCloudCommonOperationResponseHandler));
        return;
        if (paramString2 != null)
          localArrayList.add(new BasicNameValuePair("email", paramString2));
      }
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  private static void a(String paramString1, String paramString2, AppCloudLoginResponseHandler paramAppCloudLoginResponseHandler)
    throws Exception
  {
    ArrayList localArrayList = new ArrayList();
    if ((TextUtils.equals(paramString1, et.ba())) && (TextUtils.equals(paramString2, et.bc())) && (!TextUtils.isEmpty(et.aZ())))
    {
      localArrayList.add(new BasicNameValuePair("userid", et.aZ()));
      localArrayList.add(new BasicNameValuePair("password", paramString2));
    }
    while (true)
    {
      a(localArrayList, paramString2, paramAppCloudLoginResponseHandler);
      return;
      localArrayList.add(new BasicNameValuePair("username", paramString1));
      localArrayList.add(new BasicNameValuePair("password", paramString2));
    }
  }

  private static void a(List<NameValuePair> paramList, String paramString, AppCloudLoginResponseHandler paramAppCloudLoginResponseHandler)
  {
    try
    {
      FlurryAppCloudRequestManager.Get("v1/user/login", paramList, new dg(paramString, paramAppCloudLoginResponseHandler));
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  public static AppCloudUser getCurrentUser()
  {
    return cN;
  }

  public static void getUserById(String paramString, AppCloudGetUserByIDResponseHandler paramAppCloudGetUserByIDResponseHandler)
    throws Exception
  {
    AppCloudUser localAppCloudUser = new AppCloudUser();
    localAppCloudUser.setId(paramString);
    localAppCloudUser.getObjectOrUser(new dj(paramAppCloudGetUserByIDResponseHandler));
  }

  public static void loginUserWithName(String paramString1, String paramString2, String paramString3, boolean paramBoolean, AppCloudLoginResponseHandler paramAppCloudLoginResponseHandler)
  {
    if (TextUtils.isEmpty(paramString1))
    {
      paramAppCloudLoginResponseHandler.onError(new AppCloudError(400, "User name is not set."));
      return;
    }
    if (TextUtils.isEmpty(paramString2))
    {
      paramAppCloudLoginResponseHandler.onError(new AppCloudError(400, "Password is not set."));
      return;
    }
    if (TextUtils.isEmpty(paramString3))
    {
      paramAppCloudLoginResponseHandler.onError(new AppCloudError(400, "Email is not set."));
      return;
    }
    if (!paramBoolean)
      try
      {
        a(paramString1, paramString2, paramAppCloudLoginResponseHandler);
        return;
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        return;
      }
    a(paramString1, paramString2, new cz(paramAppCloudLoginResponseHandler, paramString1, paramString3, paramString2));
  }

  public static void loginWithEmail(String paramString1, String paramString2, AppCloudLoginResponseHandler paramAppCloudLoginResponseHandler)
    throws Exception
  {
    ArrayList localArrayList = new ArrayList();
    if ((TextUtils.equals(paramString1, et.bb())) && (TextUtils.equals(paramString2, et.bc())) && (!TextUtils.isEmpty(et.aZ())))
    {
      localArrayList.add(new BasicNameValuePair("userid", et.aZ()));
      localArrayList.add(new BasicNameValuePair("password", paramString2));
    }
    while (true)
    {
      a(localArrayList, paramString2, paramAppCloudLoginResponseHandler);
      return;
      localArrayList.add(new BasicNameValuePair("email", paramString1));
      localArrayList.add(new BasicNameValuePair("password", paramString2));
    }
  }

  public static void resetPasswordForUserViaEmail(String paramString, AppCloudCommonOperationResponseHandler paramAppCloudCommonOperationResponseHandler)
    throws Exception
  {
    a(null, paramString, paramAppCloudCommonOperationResponseHandler);
  }

  public static void resetPasswordForUserViaUsername(String paramString, AppCloudCommonOperationResponseHandler paramAppCloudCommonOperationResponseHandler)
    throws Exception
  {
    a(paramString, null, paramAppCloudCommonOperationResponseHandler);
  }

  protected static void setCurrentUser(AppCloudUser paramAppCloudUser)
  {
    cN = paramAppCloudUser;
  }

  public void addObserverForKey(String paramString, AppCloudValueUpdateHandler paramAppCloudValueUpdateHandler)
  {
    if (TextUtils.isEmpty(this.mId))
    {
      Log.i("AppCloudUser", "mId of user is  = " + this.mId);
      paramAppCloudValueUpdateHandler.onError(new AppCloudError(400, "Please assign an object id."));
      return;
    }
    r.a(this.mId, paramString, paramAppCloudValueUpdateHandler);
  }

  public void decrement(String paramString, float paramFloat, AppCloudCommonOperationResponseHandler paramAppCloudCommonOperationResponseHandler)
    throws Exception
  {
    if (TextUtils.isEmpty(this.mId))
    {
      AppCloudResponse localAppCloudResponse = new AppCloudResponse(new JSONObject("{code:\"400\",note:\"Please assign an object id.\"}"));
      paramAppCloudCommonOperationResponseHandler.onError(new AppCloudError(localAppCloudResponse.getHTTPResponseCode(), localAppCloudResponse.getResponseMessage()));
      return;
    }
    super.decrement(paramString, String.valueOf(paramFloat), paramAppCloudCommonOperationResponseHandler);
  }

  public void decrement(String paramString, int paramInt, AppCloudCommonOperationResponseHandler paramAppCloudCommonOperationResponseHandler)
    throws Exception
  {
    if (TextUtils.isEmpty(this.mId))
    {
      AppCloudResponse localAppCloudResponse = new AppCloudResponse(new JSONObject("{code:\"400\",note:\"Please assign an object id.\"}"));
      paramAppCloudCommonOperationResponseHandler.onError(new AppCloudError(localAppCloudResponse.getHTTPResponseCode(), localAppCloudResponse.getResponseMessage()));
      return;
    }
    super.decrement(paramString, String.valueOf(paramInt), paramAppCloudCommonOperationResponseHandler);
  }

  public void deleteWithCompletionHandler(AppCloudCommonOperationResponseHandler paramAppCloudCommonOperationResponseHandler)
    throws Exception
  {
    try
    {
      if (TextUtils.isEmpty(this.mId))
      {
        AppCloudResponse localAppCloudResponse = new AppCloudResponse(new JSONObject("{code:\"400\",note:\"Please assign an object id.\"}"));
        paramAppCloudCommonOperationResponseHandler.onError(new AppCloudError(localAppCloudResponse.getHTTPResponseCode(), localAppCloudResponse.getResponseMessage()));
        return;
      }
      delete(new dl(this, paramAppCloudCommonOperationResponseHandler));
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  public String getEmail()
  {
    return this.mEmail;
  }

  public String getPassword()
  {
    return this.password;
  }

  public String getUsername()
  {
    return this.mUsername;
  }

  public void getWithCompletionHandler(AppCloudCommonOperationResponseHandler paramAppCloudCommonOperationResponseHandler)
    throws Exception
  {
    if (TextUtils.isEmpty(this.mId))
    {
      AppCloudResponse localAppCloudResponse = new AppCloudResponse(new JSONObject("{code:\"400\",note:\"Please assign an object id.\"}"));
      paramAppCloudCommonOperationResponseHandler.onError(new AppCloudError(localAppCloudResponse.getHTTPResponseCode(), localAppCloudResponse.getResponseMessage()));
      return;
    }
    getObjectOrUser(new dk(paramAppCloudCommonOperationResponseHandler));
  }

  public void increment(String paramString, float paramFloat, AppCloudCommonOperationResponseHandler paramAppCloudCommonOperationResponseHandler)
    throws Exception
  {
    if (TextUtils.isEmpty(this.mId))
    {
      AppCloudResponse localAppCloudResponse = new AppCloudResponse(new JSONObject("{code:\"400\",note:\"Please assign an object id.\"}"));
      paramAppCloudCommonOperationResponseHandler.onError(new AppCloudError(localAppCloudResponse.getHTTPResponseCode(), localAppCloudResponse.getResponseMessage()));
      return;
    }
    super.increment(paramString, String.valueOf(paramFloat), paramAppCloudCommonOperationResponseHandler);
  }

  public void increment(String paramString, int paramInt, AppCloudCommonOperationResponseHandler paramAppCloudCommonOperationResponseHandler)
    throws Exception
  {
    if (TextUtils.isEmpty(this.mId))
    {
      AppCloudResponse localAppCloudResponse = new AppCloudResponse(new JSONObject("{code:\"400\",note:\"Please assign an object id.\"}"));
      paramAppCloudCommonOperationResponseHandler.onError(new AppCloudError(localAppCloudResponse.getHTTPResponseCode(), localAppCloudResponse.getResponseMessage()));
      return;
    }
    super.increment(paramString, String.valueOf(paramInt), paramAppCloudCommonOperationResponseHandler);
  }

  public void loginCreatingIfNewWithCompletionHandler(AppCloudLoginResponseHandler paramAppCloudLoginResponseHandler)
  {
    String str1 = et.ba();
    String str2 = et.bc();
    String str3 = et.bb();
    try
    {
      loginUserWithName(str1, str2, str3, true, paramAppCloudLoginResponseHandler);
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  public void logoutWithCompletionHandler(AppCloudCommonOperationResponseHandler paramAppCloudCommonOperationResponseHandler)
    throws Exception
  {
    FlurryAppCloudRequestManager.fInternalApi = true;
    Log.i("AppCloudUser", "Logout, mId = " + this.mId);
    FlurryAppCloudRequestManager.Put("v1/user/logout", null, new de(paramAppCloudCommonOperationResponseHandler));
  }

  public void resendSignupValidationEmailWithCompletionHandler(AppCloudCommonOperationResponseHandler paramAppCloudCommonOperationResponseHandler)
    throws Exception
  {
    FlurryAppCloudRequestManager.fInternalApi = true;
    FlurryAppCloudRequestManager.Post("v1/user/" + this.mId + "/resend", null, new df(paramAppCloudCommonOperationResponseHandler));
  }

  public void resetPasswordWithCompletionHandler(AppCloudCommonOperationResponseHandler paramAppCloudCommonOperationResponseHandler)
  {
    if ((TextUtils.isEmpty(this.mUsername)) && (TextUtils.isEmpty(this.mEmail)))
    {
      paramAppCloudCommonOperationResponseHandler.onError(new AppCloudError(400, "Current user has neither username nor email"));
      return;
    }
    if (!TextUtils.isEmpty(this.mEmail))
    {
      a(null, this.mEmail, paramAppCloudCommonOperationResponseHandler);
      return;
    }
    a(this.mUsername, null, paramAppCloudCommonOperationResponseHandler);
  }

  public void saveOrCreateWithCompletionHandler(AppCloudApplyOperationResonseHandler paramAppCloudApplyOperationResonseHandler)
    throws Exception
  {
    super.saveOrCreateWithCompletionHandler(new dd(this, paramAppCloudApplyOperationResonseHandler));
  }

  public void setEmail(String paramString)
  {
    this.mEmail = paramString;
  }

  public void setPassword(String paramString)
  {
    this.password = paramString;
  }

  public void setUsername(String paramString)
  {
    this.mUsername = paramString;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.flurry.android.AppCloudUser
 * JD-Core Version:    0.6.2
 */